
#ifndef __display_h
#define __display_h

//HAL------------------------------
/* 数码管是共阴驱动，要置1才能亮
com口是低电平有效的，要置0才能驱动
LED是共阳的，要置0才能亮 */
#define F_setA()   P2_1 = 1 
#define F_setB()   P3_3 = 1
#define F_setC()   P3_6 = 1
#define F_setD()   P2_0 = 1
#define F_setE()   P3_5 = 1
#define F_setF()   P3_4 = 1          
#define F_setG()   P1_6 = 1

#define F_clrA()   P2_1 = 0 
#define F_clrB()   P3_3 = 0
#define F_clrC()   P3_6 = 0
#define F_clrD()   P2_0 = 0
#define F_clrE()   P3_5 = 0
#define F_clrF()   P3_4 = 0          
#define F_clrG()   P1_6 = 0

// 共阴极数码管点亮条件是 ： 位控制端（公共端）需低电平，段控制端需要高电平

#define F_clrCom2() P1_5 = 0  
#define F_clrCom1() P1_7 = 0 
//set   p20 p21 p34  (to pull up input)
#define F_setCom2() P1_5 = 1  
#define F_setCom1() P1_7 = 1 

//Const---------------------------
#define F_lockDisplay()   F_clrCom1(); F_clrCom2();F_setA() ; F_setB() ; F_setC() ;F_setD() ;F_setE() ; F_setF() ;F_setG() ;
                                                  
                                                  
                                                   
                                                   
                                                  
                                                   



#define D_fontBar     0x40      //0100 0000                 
#define D_fontBlank    0X00  //0000 0000
#define D_fontE      0x79      //0100 1111
#define D_font0    0x3F      //0011 1111
#define D_font1    0x30      //0011 0000
#define D_font8	0x7F         //0111 1111

                                               
#define D_DisplayBufferSize 3
//Var------------------------------
#ifdef __dispaly_c
//displayBuffer[0]: Led indicators
//displayBuffer[1-4]: SZ[1-4]
    uint8_t displayBuffer[D_DisplayBufferSize] ;
#else
    extern uint8_t displayBuffer[D_DisplayBufferSize] ;
#endif
//Function----------------------------
void DisplayScan(void) ;//
void DisplayNumber(uint8_t number) ;


//#define 时，可以用 “\” 来把定义分成两行
#define F_displayGaoWen()  displayBuffer[2] = D_fontE ; \
                            displayBuffer[1] = 0x66  


#define F_displayAdShort()   displayBuffer[2] = D_fontE ; \
                            displayBuffer[1] = 0x5b     
//当ad短路的时候，数码管显示  E0
#define F_displayAdOff()      displayBuffer[2] = D_fontE ; \
                             displayBuffer[1] = 0x5b     
//当ad开路的时候，数码管显示 E1
#define F_displayPowerOff()   displayBuffer[1] = D_fontBar ; displayBuffer[2] = D_fontBar ; 
                           
//当上电，没有按powner建时，显示   ---                           
#define F_displayAll()    displayBuffer[2] = 0xff ;F_clrLed1;F_clrLed2; \
                           displayBuffer[1] = 0xff ; 
//没有数码管点的io口，所以无法点亮													 
//一上电的时候，自检显示 888
#define F_displayClrAll()   displayBuffer[2] = D_fontBlank ; \
                           displayBuffer[1] = D_fontBlank 
//全部数码管清空
#define F_clrAllLed()		
//led全部清零                                                                                             
                                                            
                                                            

#endif